package linePainter;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

public class MoneyRenderer extends DefaultTableCellRenderer {

    private LinePainter painter = new LinePainter();

    public MoneyRenderer() {
        this.setHorizontalAlignment(SwingConstants.RIGHT);
        this.setBorder(null);
    }

    @Override
    public Insets getInsets() {
        return new Insets(1, 1, 1, 1);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, false, hasFocus, row, column);
        this.setFont(table.getFont());
        return this;
    }

    @Override
    public void paintChildren(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        painter.paint(this, g2d, null);
        super.paintComponent(g);
    }
}
